/*
 * $Id: utils.c 456 2008-05-03 08:04:58Z jasta $
 *
 * Copyright (C) 2008 Josh Guilfoyle <jasta@devtcg.org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

#include <errno.h>

#include <glib.h>
#include <gconf/gconf-client.h>

/*****************************************************************************/

static char *home_dir = NULL;
static GConfClient *gconf = NULL;

/*****************************************************************************/

const char *five_home_base(void)
{
	if (home_dir != NULL)
		return home_dir;

	home_dir = g_build_filename(g_get_home_dir(), ".five", NULL);

	if (g_file_test(home_dir, G_FILE_TEST_IS_DIR) == FALSE)
	{
		if (g_mkdir(home_dir, 0750) == -1)
			g_error("mkdir(%s, 0750): %s", home_dir, g_strerror(errno));
	}

	return home_dir;
}

GConfClient *get_gconf_client(void)
{
	if (gconf != NULL)
		return gconf;

	gconf = gconf_client_get_default();

	return gconf;
}
